﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="question_edit.aspx.cs" Inherits="SQT.tracnghiem.Ajax.ASP.Certificate.question_edit" %>

<!DOCTYPE html>

<%@ Import Namespace="DataAccess" %>
<%@ Import Namespace="System.Linq" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <%
        int id = int.Parse(Request.QueryString["id"]);
        int thutu = int.Parse(Request.QueryString["thutu"]);
        var get_td = new TblTestDetailController().FetchAll().Where(x => x.TestDetailId == id).Single();
        var get_ques = new TblQuestionController().FetchAll().Where(x => x.QuestionTestDetail == id).ToList();
        var get_type = new TblTestDetailTypeController().FetchAll().Where(x => x.Id == get_td.TestDetailType).Single();
        var get_all_type = new TblTestDetailTypeController().FetchAll();
        string[] split = new string[get_td.TestDetailQuestion.Split(' ').Length];
        string edited = "";
        split = get_td.TestDetailQuestion.Split(' ');
        for (int i = 0; i <= get_td.TestDetailQuestion.Split(' ').Length - 1; i++)
        {
            if (split[i] == "</br>")
                edited += "/xd/";
            else
                edited += split[i];
            if (i < get_td.TestDetailQuestion.Split(' ').Length - 1)
                edited += " ";
        }
    %>
    <header class="w3-padding w3-large w3-center">Sửa Câu Hỏi</header>
    <div class="w3-hide" id="edit_ques_id"><%=id %></div>
    <div class="w3-hide" id="edit_ques_thutu"><%=thutu %></div>
    <div class="w3-row w3-padding">
        <label class="w3-quarter w3-center">Loại câu hỏi</label>
        <select class="w3-quarter" id="test_detail_type">
            <%foreach (TblTestDetailType tdt in get_all_type)
              {
                  if (tdt.Id != get_type.Id)
                  {
                  %>
            <option value="<%=tdt.Id%>"><%=tdt.TypeName%></option>
            <%}
                  else
                  { %>
            <option selected="selected" value="<%=tdt.Id%>"><%=tdt.TypeName%></option>
            <%}
              } %>
        </select>
        &nbsp;<a onclick="document.getElementById('media-collection').style.display = 'block'" class="w3-btn w3-teal w3-border"><i class="fa fa-picture-o"></i>&nbsp;Mở thư viện</a>
        <%--<a class="btn_edit_type w3-btn w3-teal w3-border w3-border-white" title="Chỉnh sửa loại câu hỏi"><i class="fa fa-cogs"></i></a>
        <a onclick="document.getElementById('themloaich').style.display='block'" class="w3-btn w3-teal w3-border w3-border-white" title="Thêm loại câu hỏi"><i class="fa fa-plus"></i></a>--%>
    </div>
    <div class="w3-row w3-padding">
        <label class="w3-quarter w3-center">Nội dung</label><textarea id="edit_ques_name" name="ndch" autofocus="autofocus" rows="4" class="w3-half"><%=edited %></textarea>
    </div>
    <%
        for(int i=1;i<=get_ques.Count;i++)
        {
         %>
    <div class="w3-row w3-padding">
        <label class="w3-quarter w3-center">Phương án <%=i %></label><input type="text" value="<%=get_ques[i-1].QuestionName %>" name="<%=get_ques[i-1].QuestionId %>" class="w3-half question_detail" />
    </div>
    <%} %>

    <div class="w3-row w3-padding">
        <label class="w3-quarter w3-center">Đáp án</label>
        <div class="radio w3-half">
            <%for (int i=1;i<=get_ques.Count;i++){ %>
            <input type="radio" name="pa" <%if(get_ques[i-1].QuestionId==get_td.TestDetailConfirm){ %>checked="checked"<%} %> value="<%=get_ques[i-1].QuestionId %>" id="pa<%=i %>" /><label for="pa<%=i %>">Phương án <%=i %></label>

            <%} %>
        </div>
    </div>
    <div class="w3-row w3-padding w3-center">
        <a class="question_edit w3-btn w3-teal w3-border w3-border-white"><i class="fa fa-save"></i>&nbsp;Lưu</a>
    </div>
</body>
</html>
